/*     */ package com.zimbra.cs.account.ldap;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.EmailUtil;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.Alias;
/*     */ import com.zimbra.cs.account.AlwaysOnCluster;
/*     */ import com.zimbra.cs.account.Config;
/*     */ import com.zimbra.cs.account.Cos;
/*     */ import com.zimbra.cs.account.DataSource;
/*     */ import com.zimbra.cs.account.DistributionList;
/*     */ import com.zimbra.cs.account.Domain;
/*     */ import com.zimbra.cs.account.DynamicGroup;
/*     */ import com.zimbra.cs.account.Entry;
/*     */ import com.zimbra.cs.account.GlobalGrant;
/*     */ import com.zimbra.cs.account.Identity;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.account.Zimlet;
/*     */ import com.zimbra.cs.ldap.IAttributes;
/*     */ import com.zimbra.cs.ldap.LdapUtil;
/*     */ import com.zimbra.cs.ldap.ZLdapFilter;
/*     */ import com.zimbra.cs.ldap.ZLdapFilterFactory;
/*     */ import com.zimbra.cs.util.Zimbra;
/*     */ import java.util.HashSet;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class LdapDIT
/*     */ {
/*     */   protected LdapProv mProv;
/*     */   protected static final String ROOT_DN = "";
/*  89 */   protected final String DEFAULT_CONFIG_BASE_DN = "cn=zimbra";
/*  90 */   protected final String DEFAULT_MAIL_BASE_DN = "";
/*     */   
/*  92 */   protected final String DEFAULT_BASE_RDN_ADMIN = "cn=admins";
/*  93 */   protected final String DEFAULT_BASE_RDN_APPADMIN = "cn=appaccts";
/*  94 */   protected final String DEFAULT_BASE_RDN_ACCOUNT = "ou=people";
/*  95 */   protected final String DEFAULT_BASE_RDN_COS = "cn=cos";
/*  96 */   protected final String DEFAULT_BASE_RDN_DYNAMICGROUP = "cn=groups";
/*  97 */   protected final String DEFAULT_BASE_RDN_GLOBAL_DYNAMICGROUP = "cn=groups";
/*  98 */   protected final String DEFAULT_BASE_RDN_MIME = "cn=mime";
/*  99 */   protected final String DEFAULT_BASE_RDN_SERVER = "cn=servers";
/* 100 */   protected final String DEFAULT_BASE_RDN_ALWAYSONCLUSTER = "cn=alwaysOnClusters";
/* 101 */   protected final String DEFAULT_BASE_RDN_UCSERVICE = "cn=ucservices";
/* 102 */   protected final String DEFAULT_BASE_RDN_SHARE_LOCATOR = "cn=sharelocators";
/* 103 */   protected final String DEFAULT_BASE_RDN_XMPPCOMPONENT = "cn=xmppcomponents";
/* 104 */   protected final String DEFAULT_BASE_RDN_ZIMLET = "cn=zimlets";
/*     */   
/*     */ 
/* 107 */   protected final String DEFAULT_NAMING_RDN_ATTR_USER = "uid";
/* 108 */   protected final String DEFAULT_NAMING_RDN_ATTR_COS = "cn";
/* 109 */   protected final String DEFAULT_NAMING_RDN_ATTR_DYNAMICGROUP = "cn";
/* 110 */   protected final String DEFAULT_NAMING_RDN_ATTR_GLOBALCONFIG = "cn";
/* 111 */   protected final String DEFAULT_NAMING_RDN_ATTR_GLOBALGRANT = "cn";
/* 112 */   protected final String DEFAULT_NAMING_RDN_ATTR_MIME = "cn";
/* 113 */   protected final String DEFAULT_NAMING_RDN_ATTR_SERVER = "cn";
/* 114 */   protected final String DEFAULT_NAMING_RDN_ATTR_ALWAYSONCLUSTER = "cn";
/* 115 */   protected final String DEFAULT_NAMING_RDN_ATTR_UCSERVICE = "cn";
/* 116 */   protected final String DEFAULT_NAMING_RDN_ATTR_SHARE_LOCATOR = "cn";
/* 117 */   protected final String DEFAULT_NAMING_RDN_ATTR_XMPPCOMPONENT = "cn";
/* 118 */   protected final String DEFAULT_NAMING_RDN_ATTR_ZIMLET = "cn";
/*     */   
/*     */   protected String BASE_DN_ZIMBRA;
/*     */   
/*     */   protected String BASE_DN_CONFIG_BRANCH;
/*     */   
/*     */   protected String BASE_DN_MAIL_BRANCH;
/*     */   
/*     */   protected String BASE_RDN_ACCOUNT;
/*     */   
/*     */   protected String BASE_RDN_DYNAMICGROUP;
/*     */   
/*     */   protected String BASE_DN_ADMIN;
/*     */   
/*     */   protected String BASE_DN_APPADMIN;
/*     */   
/*     */   protected String BASE_DN_ACCOUNT;
/*     */   protected String BASE_DN_COS;
/*     */   protected String BASE_DN_GLOBAL_DYNAMICGROUP;
/*     */   protected String BASE_DN_MIME;
/*     */   protected String BASE_DN_SERVER;
/*     */   protected String BASE_DN_ALWAYSONCLUSTER;
/*     */   protected String BASE_DN_UCSERVICE;
/*     */   protected String BASE_DN_SHARE_LOCATOR;
/*     */   protected String BASE_DN_XMPPCOMPONENT;
/*     */   protected String BASE_DN_ZIMLET;
/*     */   protected String NAMING_RDN_ATTR_USER;
/*     */   protected String NAMING_RDN_ATTR_COS;
/*     */   protected String NAMING_RDN_ATTR_GLOBALCONFIG;
/*     */   protected String NAMING_RDN_ATTR_GLOBALGRANT;
/*     */   protected String NAMING_RDN_ATTR_DYNAMICGROUP;
/*     */   protected String NAMING_RDN_ATTR_MIME;
/*     */   protected String NAMING_RDN_ATTR_SERVER;
/*     */   protected String NAMING_RDN_ATTR_ALWAYSONCLUSTER;
/*     */   protected String NAMING_RDN_ATTR_UCSERVICE;
/*     */   protected String NAMING_RDN_ATTR_SHARE_LOCATOR;
/*     */   protected String NAMING_RDN_ATTR_XMPPCOMPONENT;
/*     */   protected String NAMING_RDN_ATTR_ZIMLET;
/*     */   protected String DN_GLOBALCONFIG;
/*     */   protected String DN_GLOBALGRANT;
/*     */   
/*     */   public LdapDIT(LdapProv prov)
/*     */   {
/* 161 */     this.mProv = prov;
/*     */     
/* 163 */     init();
/* 164 */     verify();
/*     */   }
/*     */   
/*     */   protected void init() {
/* 168 */     this.BASE_DN_CONFIG_BRANCH = "cn=zimbra";
/* 169 */     this.BASE_DN_MAIL_BRANCH = "";
/*     */     
/* 171 */     this.BASE_RDN_ACCOUNT = "ou=people";
/* 172 */     this.BASE_RDN_DYNAMICGROUP = "cn=groups";
/*     */     
/* 174 */     this.NAMING_RDN_ATTR_USER = "uid";
/* 175 */     this.NAMING_RDN_ATTR_COS = "cn";
/* 176 */     this.NAMING_RDN_ATTR_DYNAMICGROUP = "cn";
/* 177 */     this.NAMING_RDN_ATTR_GLOBALCONFIG = "cn";
/* 178 */     this.NAMING_RDN_ATTR_GLOBALGRANT = "cn";
/* 179 */     this.NAMING_RDN_ATTR_MIME = "cn";
/* 180 */     this.NAMING_RDN_ATTR_SERVER = "cn";
/* 181 */     this.NAMING_RDN_ATTR_ALWAYSONCLUSTER = "cn";
/* 182 */     this.NAMING_RDN_ATTR_UCSERVICE = "cn";
/* 183 */     this.NAMING_RDN_ATTR_SHARE_LOCATOR = "cn";
/* 184 */     this.NAMING_RDN_ATTR_XMPPCOMPONENT = "cn";
/* 185 */     this.NAMING_RDN_ATTR_ZIMLET = "cn";
/*     */     
/* 187 */     this.DN_GLOBALCONFIG = (this.NAMING_RDN_ATTR_GLOBALCONFIG + "=config" + "," + this.BASE_DN_CONFIG_BRANCH);
/* 188 */     this.DN_GLOBALGRANT = (this.NAMING_RDN_ATTR_GLOBALGRANT + "=globalgrant" + "," + this.BASE_DN_CONFIG_BRANCH);
/*     */     
/* 190 */     this.BASE_DN_ADMIN = ("cn=admins," + this.BASE_DN_CONFIG_BRANCH);
/* 191 */     this.BASE_DN_APPADMIN = ("cn=appaccts," + this.BASE_DN_CONFIG_BRANCH);
/* 192 */     this.BASE_DN_COS = ("cn=cos," + this.BASE_DN_CONFIG_BRANCH);
/* 193 */     this.BASE_DN_GLOBAL_DYNAMICGROUP = ("cn=groups," + this.BASE_DN_CONFIG_BRANCH);
/* 194 */     this.BASE_DN_MIME = ("cn=mime," + this.DN_GLOBALCONFIG);
/* 195 */     this.BASE_DN_SERVER = ("cn=servers," + this.BASE_DN_CONFIG_BRANCH);
/* 196 */     this.BASE_DN_ALWAYSONCLUSTER = ("cn=alwaysOnClusters," + this.BASE_DN_CONFIG_BRANCH);
/* 197 */     this.BASE_DN_UCSERVICE = ("cn=ucservices," + this.BASE_DN_CONFIG_BRANCH);
/* 198 */     this.BASE_DN_SHARE_LOCATOR = ("cn=sharelocators," + this.BASE_DN_CONFIG_BRANCH);
/* 199 */     this.BASE_DN_XMPPCOMPONENT = ("cn=xmppcomponents," + this.BASE_DN_CONFIG_BRANCH);
/* 200 */     this.BASE_DN_ZIMLET = ("cn=zimlets," + this.BASE_DN_CONFIG_BRANCH);
/*     */     
/* 202 */     this.BASE_DN_ZIMBRA = "";
/*     */   }
/*     */   
/*     */   private final void verify()
/*     */   {
/* 207 */     if ((this.BASE_DN_ZIMBRA == null) || (this.BASE_DN_CONFIG_BRANCH == null) || (this.BASE_DN_MAIL_BRANCH == null) || (this.BASE_RDN_ACCOUNT == null) || (this.BASE_RDN_DYNAMICGROUP == null) || (this.NAMING_RDN_ATTR_USER == null) || (this.NAMING_RDN_ATTR_COS == null) || (this.NAMING_RDN_ATTR_DYNAMICGROUP == null) || (this.NAMING_RDN_ATTR_GLOBALCONFIG == null) || (this.NAMING_RDN_ATTR_GLOBALGRANT == null) || (this.NAMING_RDN_ATTR_MIME == null) || (this.NAMING_RDN_ATTR_SERVER == null) || (this.NAMING_RDN_ATTR_ALWAYSONCLUSTER == null) || (this.NAMING_RDN_ATTR_UCSERVICE == null) || (this.NAMING_RDN_ATTR_SHARE_LOCATOR == null) || (this.NAMING_RDN_ATTR_ZIMLET == null) || (this.BASE_DN_ADMIN == null) || (this.BASE_DN_APPADMIN == null) || (this.BASE_DN_COS == null) || (this.BASE_DN_GLOBAL_DYNAMICGROUP == null) || (this.BASE_DN_MIME == null) || (this.BASE_DN_SERVER == null) || (this.BASE_DN_ALWAYSONCLUSTER == null) || (this.BASE_DN_UCSERVICE == null) || (this.BASE_DN_XMPPCOMPONENT == null) || (this.BASE_DN_ZIMLET == null) || (this.DN_GLOBALCONFIG == null) || (this.DN_GLOBALGRANT == null))
/*     */     {
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 235 */       Zimbra.halt("Unable to initialize LDAP DIT"); }
/*     */   }
/*     */   
/*     */   public static boolean isZimbraDefault(LdapDIT dit) {
/* 239 */     return dit.getClass() == LdapDIT.class;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public String zimbraBaseDN()
/*     */   {
/* 246 */     return this.BASE_DN_ZIMBRA;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public String configBranchBaseDN()
/*     */   {
/* 253 */     return this.BASE_DN_CONFIG_BRANCH;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public String mailBranchBaseDN()
/*     */   {
/* 260 */     return this.BASE_DN_MAIL_BRANCH;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String accountNamingRdnAttr()
/*     */   {
/* 269 */     return this.NAMING_RDN_ATTR_USER;
/*     */   }
/*     */   
/*     */   protected String emailToDN(String localPart, String domain) throws ServiceException {
/* 273 */     return this.NAMING_RDN_ATTR_USER + "=" + LdapUtil.escapeRDNValue(localPart) + "," + domainToAccountBaseDN(domain);
/*     */   }
/*     */   
/*     */   protected String emailToDN(String email) throws ServiceException {
/* 277 */     String[] parts = EmailUtil.getLocalPartAndDomain(email);
/* 278 */     return emailToDN(parts[0], parts[1]);
/*     */   }
/*     */   
/*     */   public String accountDNCreate(String baseDn, IAttributes attrs, String localPart, String domain) throws ServiceException
/*     */   {
/* 283 */     if (baseDn != null) {
/* 284 */       throw ServiceException.INVALID_REQUEST("base dn is not supported in DIT impl " + getClass().getCanonicalName(), null);
/*     */     }
/* 286 */     return emailToDN(localPart, domain);
/*     */   }
/*     */   
/*     */   public String accountDNRename(String oldDn, String newLocalPart, String newDomain) throws ServiceException
/*     */   {
/* 291 */     return emailToDN(newLocalPart, newDomain);
/*     */   }
/*     */   
/*     */   public String dnToEmail(String dn, IAttributes attrs) throws ServiceException
/*     */   {
/* 296 */     return dnToEmail(dn, null, attrs);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String dnToEmail(String dn, String namingAttr, IAttributes attrs)
/*     */     throws ServiceException
/*     */   {
/* 309 */     String[] parts = dn.split(",");
/* 310 */     StringBuffer domain = new StringBuffer(dn.length());
/*     */     
/* 312 */     String alternateNamingAttr = null;
/*     */     
/* 314 */     if (namingAttr != null) {
/* 315 */       namingAttr = namingAttr + "=";
/*     */     } else {
/* 317 */       namingAttr = accountNamingRdnAttr() + "=";
/* 318 */       alternateNamingAttr = dynamicGroupNamingRdnAttr() + "=";
/*     */     }
/*     */     
/* 321 */     String namingAttrValue = null;
/*     */     
/* 323 */     for (int i = 0; i < parts.length; i++) {
/* 324 */       if (parts[i].startsWith("dc=")) {
/* 325 */         if (domain.length() > 0)
/* 326 */           domain.append(".");
/* 327 */         domain.append(LdapUtil.unescapeRDNValue(parts[i].substring(3)));
/* 328 */       } else if ((i == 0) && (parts[i].startsWith(namingAttr))) {
/* 329 */         namingAttrValue = LdapUtil.unescapeRDNValue(parts[i].substring(namingAttr.length()));
/* 330 */       } else if ((alternateNamingAttr != null) && (i == 0) && (parts[i].startsWith(alternateNamingAttr))) {
/* 331 */         namingAttrValue = LdapUtil.unescapeRDNValue(parts[i].substring(alternateNamingAttr.length()));
/*     */       }
/*     */     }
/* 334 */     if (namingAttrValue == null) {
/* 335 */       throw ServiceException.FAILURE("unable to map dn [" + dn + "] to email", null);
/*     */     }
/* 337 */     if (domain.length() == 0) {
/* 338 */       return namingAttrValue;
/*     */     }
/* 340 */     return namingAttrValue + '@' + domain;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String adminBaseDN()
/*     */   {
/* 350 */     return this.BASE_DN_ADMIN;
/*     */   }
/*     */   
/*     */   public String appAdminBaseDN() {
/* 354 */     return this.BASE_DN_APPADMIN;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String aliasDN(String targetDn, String targetDomain, String aliasLocalPart, String aliasDomain)
/*     */     throws ServiceException
/*     */   {
/* 369 */     return emailToDN(aliasLocalPart, aliasDomain);
/*     */   }
/*     */   
/*     */   public String aliasDNRename(String targetNewDn, String targetNewDomain, String newAliasEmail) throws ServiceException {
/* 373 */     return emailToDN(newAliasEmail);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String cosBaseDN()
/*     */   {
/* 388 */     return this.BASE_DN_COS;
/*     */   }
/*     */   
/*     */   public String cosNametoDN(String name) {
/* 392 */     return this.NAMING_RDN_ATTR_COS + "=" + LdapUtil.escapeRDNValue(name) + "," + this.BASE_DN_COS;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String distributionListDNCreate(String baseDn, IAttributes attrs, String localPart, String domain)
/*     */     throws ServiceException
/*     */   {
/* 402 */     if (baseDn != null) {
/* 403 */       throw ServiceException.INVALID_REQUEST("base dn is not supported in DIT impl " + getClass().getCanonicalName(), null);
/*     */     }
/* 405 */     return emailToDN(localPart, domain);
/*     */   }
/*     */   
/*     */   public String distributionListDNRename(String oldDn, String newLocalPart, String newDomain) throws ServiceException {
/* 409 */     return emailToDN(newLocalPart, newDomain);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String domainBaseDN()
/*     */   {
/* 419 */     return mailBranchBaseDN();
/*     */   }
/*     */   
/*     */   public String domainNameToDN(String domainName) {
/* 423 */     String[] parts = domainName.split("\\.");
/* 424 */     String[] dns = domainToDNs(parts);
/* 425 */     return dns[0];
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String[] domainToDNs(String[] parts)
/*     */   {
/* 436 */     return domainToDNsInternal(parts, null);
/*     */   }
/*     */   
/*     */   protected String[] domainToDNsInternal(String[] parts, String base) {
/* 440 */     String[] dns = new String[parts.length];
/* 441 */     for (int i = parts.length - 1; i >= 0; i--) {
/* 442 */       dns[i] = LdapUtil.domainToDN(parts, i);
/* 443 */       if (base != null) {
/* 444 */         dns[i] = (dns[i] + "," + base);
/*     */       }
/*     */     }
/* 447 */     return dns;
/*     */   }
/*     */   
/*     */   public String domainToAccountSearchDN(String domain) throws ServiceException
/*     */   {
/* 452 */     return domainDNToAccountBaseDN(LdapUtil.domainToDN(domain));
/*     */   }
/*     */   
/*     */   public String domainDNToAccountSearchDN(String domainDN) throws ServiceException
/*     */   {
/* 457 */     return domainDNToAccountBaseDN(domainDN);
/*     */   }
/*     */   
/*     */   private String domainToAccountBaseDN(String domain) throws ServiceException
/*     */   {
/* 462 */     return domainDNToAccountBaseDN(LdapUtil.domainToDN(domain));
/*     */   }
/*     */   
/*     */   public String domainDNToAccountBaseDN(String domainDN) throws ServiceException
/*     */   {
/* 467 */     if (this.BASE_RDN_ACCOUNT.length() == 0) {
/* 468 */       return domainDN;
/*     */     }
/* 470 */     return this.BASE_RDN_ACCOUNT + "," + domainDN;
/*     */   }
/*     */   
/*     */   public String domainDNToDynamicGroupsBaseDN(String domainDN) throws ServiceException
/*     */   {
/* 475 */     if (this.BASE_RDN_DYNAMICGROUP.length() == 0) {
/* 476 */       return domainDN;
/*     */     }
/* 478 */     return this.BASE_RDN_DYNAMICGROUP + "," + domainDN;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String globalDynamicGroupBaseDN()
/*     */   {
/* 488 */     return this.BASE_DN_GLOBAL_DYNAMICGROUP;
/*     */   }
/*     */   
/*     */   public String dynamicGroupNamingRdnAttr() {
/* 492 */     return this.NAMING_RDN_ATTR_DYNAMICGROUP;
/*     */   }
/*     */   
/*     */   public String dynamicGroupNameLocalPartToDN(String name, String domainDN) throws ServiceException
/*     */   {
/* 497 */     return this.NAMING_RDN_ATTR_DYNAMICGROUP + "=" + LdapUtil.escapeRDNValue(name) + "," + domainDNToDynamicGroupsBaseDN(domainDN);
/*     */   }
/*     */   
/*     */   public String dynamicGroupUnitNameToDN(String unitName, String parentDN)
/*     */     throws ServiceException
/*     */   {
/* 503 */     return this.NAMING_RDN_ATTR_DYNAMICGROUP + "=" + LdapUtil.escapeRDNValue(unitName) + "," + parentDN;
/*     */   }
/*     */   
/*     */   public String filterDynamicGroupsByDomain(Domain domain, boolean includeObjectClass)
/*     */   {
/* 508 */     if (includeObjectClass) {
/* 509 */       return "(objectclass=zimbraGroup)";
/*     */     }
/* 511 */     return "";
/*     */   }
/*     */   
/*     */   public String dynamicGroupDNRename(String oldDn, String newLocalPart, String newDomain) throws ServiceException
/*     */   {
/* 516 */     String newDomainDN = domainNameToDN(newDomain);
/* 517 */     return dynamicGroupNameLocalPartToDN(newLocalPart, newDomainDN);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public String domainDNToGroupsBaseDN(String domainDN)
/*     */     throws ServiceException
/*     */   {
/* 526 */     return domainDN;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String configDN()
/*     */   {
/* 545 */     return this.DN_GLOBALCONFIG;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String globalGrantDN()
/*     */   {
/* 554 */     return this.DN_GLOBALGRANT;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String mimeBaseDN()
/*     */   {
/* 571 */     return this.BASE_DN_MIME;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String serverBaseDN()
/*     */   {
/* 580 */     return this.BASE_DN_SERVER;
/*     */   }
/*     */   
/*     */   public String serverNameToDN(String name) {
/* 584 */     return this.NAMING_RDN_ATTR_SERVER + "=" + LdapUtil.escapeRDNValue(name) + "," + this.BASE_DN_SERVER;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String alwaysOnClusterBaseDN()
/*     */   {
/* 593 */     return this.BASE_DN_ALWAYSONCLUSTER;
/*     */   }
/*     */   
/*     */   public String alwaysOnClusterNameToDN(String name) {
/* 597 */     return this.NAMING_RDN_ATTR_ALWAYSONCLUSTER + "=" + LdapUtil.escapeRDNValue(name) + "," + this.BASE_DN_ALWAYSONCLUSTER;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String ucServiceBaseDN()
/*     */   {
/* 606 */     return this.BASE_DN_UCSERVICE;
/*     */   }
/*     */   
/*     */   public String ucServiceNameToDN(String name) {
/* 610 */     return this.NAMING_RDN_ATTR_UCSERVICE + "=" + LdapUtil.escapeRDNValue(name) + "," + this.BASE_DN_UCSERVICE;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String shareLocatorBaseDN()
/*     */   {
/* 620 */     return this.BASE_DN_SHARE_LOCATOR;
/*     */   }
/*     */   
/*     */   public String shareLocatorIdToDN(String id) {
/* 624 */     return this.NAMING_RDN_ATTR_SHARE_LOCATOR + "=" + LdapUtil.escapeRDNValue(id) + "," + this.BASE_DN_SHARE_LOCATOR;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String xmppcomponentBaseDN()
/*     */   {
/* 634 */     return this.BASE_DN_XMPPCOMPONENT;
/*     */   }
/*     */   
/*     */   public String xmppcomponentNameToDN(String name) {
/* 638 */     return this.NAMING_RDN_ATTR_XMPPCOMPONENT + "=" + LdapUtil.escapeRDNValue(name) + "," + this.BASE_DN_XMPPCOMPONENT;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String zimletBaseDN()
/*     */   {
/* 648 */     return this.BASE_DN_ZIMLET;
/*     */   }
/*     */   
/*     */   public String zimletNameToDN(String name) {
/* 652 */     return this.NAMING_RDN_ATTR_ZIMLET + "=" + LdapUtil.escapeRDNValue(name) + "," + this.BASE_DN_ZIMLET;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public ZLdapFilter filterAccountsByDomainAndServer(Domain domain, Server server)
/*     */   {
/* 672 */     return ZLdapFilterFactory.getInstance().accountsHomedOnServer(server.getServiceHostname());
/*     */   }
/*     */   
/*     */   public ZLdapFilter filterAccountsOnlyByDomainAndServer(Domain domain, Server server) {
/* 676 */     return ZLdapFilterFactory.getInstance().accountsHomedOnServerAccountsOnly(server.getServiceHostname());
/*     */   }
/*     */   
/*     */   public ZLdapFilter filterCalendarResourceByDomainAndServer(Domain domain, Server server) {
/* 680 */     return ZLdapFilterFactory.getInstance().calendarResourcesHomedOnServer(server.getServiceHostname());
/*     */   }
/*     */   
/*     */   public ZLdapFilter filterAccountsOnlyByDomain(Domain domain) {
/* 684 */     return ZLdapFilterFactory.getInstance().allAccountsOnly();
/*     */   }
/*     */   
/*     */   public ZLdapFilter filterCalendarResourcesByDomain(Domain domain) {
/* 688 */     return ZLdapFilterFactory.getInstance().allCalendarResources();
/*     */   }
/*     */   
/*     */   public ZLdapFilter filterDistributionListsByDomain(Domain domain) {
/* 692 */     return ZLdapFilterFactory.getInstance().allDistributionLists();
/*     */   }
/*     */   
/*     */   public ZLdapFilter filterGroupsByDomain(Domain domain) {
/* 696 */     return ZLdapFilterFactory.getInstance().allGroups();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public SpecialAttrs handleSpecialAttrs(Map<String, Object> attrs)
/*     */     throws ServiceException
/*     */   {
/* 705 */     SpecialAttrs specialAttrs = new SpecialAttrs();
/* 706 */     if (attrs != null) {
/* 707 */       specialAttrs.handleZimbraId(attrs);
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 714 */     return specialAttrs;
/*     */   }
/*     */   
/*     */   public String getNamingRdnAttr(Entry entry) throws ServiceException {
/* 718 */     if (((entry instanceof Account)) || ((entry instanceof DistributionList)) || ((entry instanceof Alias)))
/*     */     {
/*     */ 
/* 721 */       return this.NAMING_RDN_ATTR_USER; }
/* 722 */     if ((entry instanceof Cos))
/* 723 */       return this.NAMING_RDN_ATTR_COS;
/* 724 */     if ((entry instanceof Config))
/* 725 */       return this.NAMING_RDN_ATTR_GLOBALCONFIG;
/* 726 */     if ((entry instanceof DataSource))
/* 727 */       return "zimbraDataSourceName";
/* 728 */     if ((entry instanceof Domain))
/* 729 */       return "dc";
/* 730 */     if ((entry instanceof Identity))
/* 731 */       return "zimbraPrefIdentityName";
/* 732 */     if ((entry instanceof GlobalGrant))
/* 733 */       return this.NAMING_RDN_ATTR_GLOBALGRANT;
/* 734 */     if ((entry instanceof DynamicGroup))
/* 735 */       return this.NAMING_RDN_ATTR_DYNAMICGROUP;
/* 736 */     if ((entry instanceof Server))
/* 737 */       return this.NAMING_RDN_ATTR_SERVER;
/* 738 */     if ((entry instanceof AlwaysOnCluster))
/* 739 */       return this.NAMING_RDN_ATTR_ALWAYSONCLUSTER;
/* 740 */     if ((entry instanceof Server))
/* 741 */       return this.NAMING_RDN_ATTR_UCSERVICE;
/* 742 */     if ((entry instanceof Zimlet)) {
/* 743 */       return this.NAMING_RDN_ATTR_ZIMLET;
/*     */     }
/* 745 */     throw ServiceException.FAILURE("entry type " + entry.getClass().getCanonicalName() + " is not supported by getNamingRdnAttr", null);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean isUnder(String parentDn, String dn)
/*     */   {
/* 758 */     if ((!parentDn.equals("")) && 
/* 759 */       (!dn.toLowerCase().endsWith(parentDn.toLowerCase()))) {
/* 760 */       return false;
/*     */     }
/* 762 */     return true;
/*     */   }
/*     */   
/*     */   private void addBase(Set<String> bases, String base)
/*     */   {
/* 767 */     boolean add = true;
/* 768 */     for (String b : bases) {
/* 769 */       if (isUnder(b, base)) {
/* 770 */         add = false;
/* 771 */         break;
/*     */       }
/*     */     }
/* 774 */     if (add) {
/* 775 */       bases.add(base);
/*     */     }
/*     */   }
/*     */   
/*     */   public String[] getSearchBases(int flags) {
/* 780 */     Set<String> bases = new HashSet();
/*     */     
/* 782 */     boolean accounts = (flags & 0x1) != 0;
/* 783 */     boolean aliases = (flags & 0x2) != 0;
/* 784 */     boolean lists = (flags & 0x4) != 0;
/* 785 */     boolean dynamicgroups = (flags & 0x100) != 0;
/* 786 */     boolean calendarResources = (flags & 0x8) != 0;
/* 787 */     boolean domains = (flags & 0x10) != 0;
/* 788 */     boolean coses = (flags & 0x20) != 0;
/* 789 */     boolean servers = (flags & 0x40) != 0;
/* 790 */     boolean ucservices = (flags & 0x80) != 0;
/*     */     
/* 792 */     if ((accounts) || (aliases) || (lists) || (dynamicgroups) || (calendarResources)) {
/* 793 */       addBase(bases, mailBranchBaseDN());
/*     */     }
/*     */     
/* 796 */     if (accounts) {
/* 797 */       addBase(bases, adminBaseDN());
/*     */     }
/*     */     
/* 800 */     if (domains) {
/* 801 */       addBase(bases, domainBaseDN());
/*     */     }
/*     */     
/* 804 */     if (coses) {
/* 805 */       addBase(bases, cosBaseDN());
/*     */     }
/*     */     
/* 808 */     if (servers) {
/* 809 */       addBase(bases, serverBaseDN());
/*     */     }
/*     */     
/* 812 */     if (ucservices) {
/* 813 */       addBase(bases, ucServiceBaseDN());
/*     */     }
/*     */     
/* 816 */     return (String[])bases.toArray(new String[bases.size()]);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/LdapDIT.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */